﻿#region Using directives

using System;
using System.Data;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;

using BesAsm.MasterData.Entities;
using BesAsm.MasterData.Data;

#endregion

namespace BesAsm.MasterData.Data.Bases
{	
	///<summary>
	/// This class is the base class for any <see cref="WeirProviderBase"/> implementation.
	/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
	///</summary>
	public abstract partial class WeirProviderBaseCore : EntityProviderBase<BesAsm.MasterData.Entities.Weir, BesAsm.MasterData.Entities.WeirKey>
	{		
		#region Get from Many To Many Relationship Functions
		#endregion	
		
		#region Delete Methods

		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to delete.</param>
		/// <returns>Returns true if operation suceeded.</returns>
		public override bool Delete(TransactionManager transactionManager, BesAsm.MasterData.Entities.WeirKey key)
		{
			return Delete(transactionManager, key.WeirId);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="_weirId">Primary key, weir ID. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public bool Delete(System.Int32 _weirId)
		{
			return Delete(null, _weirId);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_weirId">Primary key, weir ID. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public abstract bool Delete(TransactionManager transactionManager, System.Int32 _weirId);		
		
		#endregion Delete Methods
		
		#region Get By Foreign Key Functions
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_LINKS key.
		///		FK_WEIRS_LINKS Description: 
		/// </summary>
		/// <param name="_linkId">Foreign key to LINKS.  Indicates the link along which the weir will be placed.  The link must have its us_node_id match the record's us_node_id.  If this field is empty, ds_node_id must not be empty.  If both are not empty, ds_node_id overrides.</param>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		public TList<Weir> GetByLinkId(System.Int32? _linkId)
		{
			int count = -1;
			return GetByLinkId(_linkId, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_LINKS key.
		///		FK_WEIRS_LINKS Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_linkId">Foreign key to LINKS.  Indicates the link along which the weir will be placed.  The link must have its us_node_id match the record's us_node_id.  If this field is empty, ds_node_id must not be empty.  If both are not empty, ds_node_id overrides.</param>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		/// <remarks></remarks>
		public TList<Weir> GetByLinkId(TransactionManager transactionManager, System.Int32? _linkId)
		{
			int count = -1;
			return GetByLinkId(transactionManager, _linkId, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_LINKS key.
		///		FK_WEIRS_LINKS Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_linkId">Foreign key to LINKS.  Indicates the link along which the weir will be placed.  The link must have its us_node_id match the record's us_node_id.  If this field is empty, ds_node_id must not be empty.  If both are not empty, ds_node_id overrides.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		public TList<Weir> GetByLinkId(TransactionManager transactionManager, System.Int32? _linkId, int start, int pageLength)
		{
			int count = -1;
			return GetByLinkId(transactionManager, _linkId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_LINKS key.
		///		fkWeirsLinks Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_linkId">Foreign key to LINKS.  Indicates the link along which the weir will be placed.  The link must have its us_node_id match the record's us_node_id.  If this field is empty, ds_node_id must not be empty.  If both are not empty, ds_node_id overrides.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		public TList<Weir> GetByLinkId(System.Int32? _linkId, int start, int pageLength)
		{
			int count =  -1;
			return GetByLinkId(null, _linkId, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_LINKS key.
		///		fkWeirsLinks Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_linkId">Foreign key to LINKS.  Indicates the link along which the weir will be placed.  The link must have its us_node_id match the record's us_node_id.  If this field is empty, ds_node_id must not be empty.  If both are not empty, ds_node_id overrides.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		public TList<Weir> GetByLinkId(System.Int32? _linkId, int start, int pageLength,out int count)
		{
			return GetByLinkId(null, _linkId, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_LINKS key.
		///		FK_WEIRS_LINKS Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_linkId">Foreign key to LINKS.  Indicates the link along which the weir will be placed.  The link must have its us_node_id match the record's us_node_id.  If this field is empty, ds_node_id must not be empty.  If both are not empty, ds_node_id overrides.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		public abstract TList<Weir> GetByLinkId(TransactionManager transactionManager, System.Int32? _linkId, int start, int pageLength, out int count);
		
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_NODES_DS key.
		///		FK_WEIRS_NODES_DS Description: 
		/// </summary>
		/// <param name="_dsNodeId">Downstream node ID, foreign key to NODES.  If empty, then the link_id must not be empty.  If both are not empty, ds_node_id overrides.</param>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		public TList<Weir> GetByDsNodeId(System.Int32? _dsNodeId)
		{
			int count = -1;
			return GetByDsNodeId(_dsNodeId, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_NODES_DS key.
		///		FK_WEIRS_NODES_DS Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_dsNodeId">Downstream node ID, foreign key to NODES.  If empty, then the link_id must not be empty.  If both are not empty, ds_node_id overrides.</param>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		/// <remarks></remarks>
		public TList<Weir> GetByDsNodeId(TransactionManager transactionManager, System.Int32? _dsNodeId)
		{
			int count = -1;
			return GetByDsNodeId(transactionManager, _dsNodeId, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_NODES_DS key.
		///		FK_WEIRS_NODES_DS Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_dsNodeId">Downstream node ID, foreign key to NODES.  If empty, then the link_id must not be empty.  If both are not empty, ds_node_id overrides.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		public TList<Weir> GetByDsNodeId(TransactionManager transactionManager, System.Int32? _dsNodeId, int start, int pageLength)
		{
			int count = -1;
			return GetByDsNodeId(transactionManager, _dsNodeId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_NODES_DS key.
		///		fkWeirsNodesDs Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_dsNodeId">Downstream node ID, foreign key to NODES.  If empty, then the link_id must not be empty.  If both are not empty, ds_node_id overrides.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		public TList<Weir> GetByDsNodeId(System.Int32? _dsNodeId, int start, int pageLength)
		{
			int count =  -1;
			return GetByDsNodeId(null, _dsNodeId, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_NODES_DS key.
		///		fkWeirsNodesDs Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_dsNodeId">Downstream node ID, foreign key to NODES.  If empty, then the link_id must not be empty.  If both are not empty, ds_node_id overrides.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		public TList<Weir> GetByDsNodeId(System.Int32? _dsNodeId, int start, int pageLength,out int count)
		{
			return GetByDsNodeId(null, _dsNodeId, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_NODES_DS key.
		///		FK_WEIRS_NODES_DS Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_dsNodeId">Downstream node ID, foreign key to NODES.  If empty, then the link_id must not be empty.  If both are not empty, ds_node_id overrides.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		public abstract TList<Weir> GetByDsNodeId(TransactionManager transactionManager, System.Int32? _dsNodeId, int start, int pageLength, out int count);
		
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_NODES_US key.
		///		FK_WEIRS_NODES_US Description: 
		/// </summary>
		/// <param name="_usNodeId">Upstream node ID, foreign key to NODES</param>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		public TList<Weir> GetByUsNodeId(System.Int32 _usNodeId)
		{
			int count = -1;
			return GetByUsNodeId(_usNodeId, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_NODES_US key.
		///		FK_WEIRS_NODES_US Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_usNodeId">Upstream node ID, foreign key to NODES</param>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		/// <remarks></remarks>
		public TList<Weir> GetByUsNodeId(TransactionManager transactionManager, System.Int32 _usNodeId)
		{
			int count = -1;
			return GetByUsNodeId(transactionManager, _usNodeId, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_NODES_US key.
		///		FK_WEIRS_NODES_US Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_usNodeId">Upstream node ID, foreign key to NODES</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		public TList<Weir> GetByUsNodeId(TransactionManager transactionManager, System.Int32 _usNodeId, int start, int pageLength)
		{
			int count = -1;
			return GetByUsNodeId(transactionManager, _usNodeId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_NODES_US key.
		///		fkWeirsNodesUs Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_usNodeId">Upstream node ID, foreign key to NODES</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		public TList<Weir> GetByUsNodeId(System.Int32 _usNodeId, int start, int pageLength)
		{
			int count =  -1;
			return GetByUsNodeId(null, _usNodeId, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_NODES_US key.
		///		fkWeirsNodesUs Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_usNodeId">Upstream node ID, foreign key to NODES</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		public TList<Weir> GetByUsNodeId(System.Int32 _usNodeId, int start, int pageLength,out int count)
		{
			return GetByUsNodeId(null, _usNodeId, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_NODES_US key.
		///		FK_WEIRS_NODES_US Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_usNodeId">Upstream node ID, foreign key to NODES</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		public abstract TList<Weir> GetByUsNodeId(TransactionManager transactionManager, System.Int32 _usNodeId, int start, int pageLength, out int count);
		
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_STATUSES key.
		///		FK_WEIRS_STATUSES Description: 
		/// </summary>
		/// <param name="_status">Status of record, in terms of usability for further analysis and general state of data</param>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		public TList<Weir> GetByStatus(System.String _status)
		{
			int count = -1;
			return GetByStatus(_status, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_STATUSES key.
		///		FK_WEIRS_STATUSES Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_status">Status of record, in terms of usability for further analysis and general state of data</param>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		/// <remarks></remarks>
		public TList<Weir> GetByStatus(TransactionManager transactionManager, System.String _status)
		{
			int count = -1;
			return GetByStatus(transactionManager, _status, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_STATUSES key.
		///		FK_WEIRS_STATUSES Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_status">Status of record, in terms of usability for further analysis and general state of data</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		public TList<Weir> GetByStatus(TransactionManager transactionManager, System.String _status, int start, int pageLength)
		{
			int count = -1;
			return GetByStatus(transactionManager, _status, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_STATUSES key.
		///		fkWeirsStatuses Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_status">Status of record, in terms of usability for further analysis and general state of data</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		public TList<Weir> GetByStatus(System.String _status, int start, int pageLength)
		{
			int count =  -1;
			return GetByStatus(null, _status, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_STATUSES key.
		///		fkWeirsStatuses Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_status">Status of record, in terms of usability for further analysis and general state of data</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		public TList<Weir> GetByStatus(System.String _status, int start, int pageLength,out int count)
		{
			return GetByStatus(null, _status, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_STATUSES key.
		///		FK_WEIRS_STATUSES Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_status">Status of record, in terms of usability for further analysis and general state of data</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		public abstract TList<Weir> GetByStatus(TransactionManager transactionManager, System.String _status, int start, int pageLength, out int count);
		
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_WEIR_TYPES key.
		///		FK_WEIRS_WEIR_TYPES Description: 
		/// </summary>
		/// <param name="_weirType">Foreign key to WEIR_TYPES</param>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		public TList<Weir> GetByWeirType(System.String _weirType)
		{
			int count = -1;
			return GetByWeirType(_weirType, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_WEIR_TYPES key.
		///		FK_WEIRS_WEIR_TYPES Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_weirType">Foreign key to WEIR_TYPES</param>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		/// <remarks></remarks>
		public TList<Weir> GetByWeirType(TransactionManager transactionManager, System.String _weirType)
		{
			int count = -1;
			return GetByWeirType(transactionManager, _weirType, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_WEIR_TYPES key.
		///		FK_WEIRS_WEIR_TYPES Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_weirType">Foreign key to WEIR_TYPES</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		public TList<Weir> GetByWeirType(TransactionManager transactionManager, System.String _weirType, int start, int pageLength)
		{
			int count = -1;
			return GetByWeirType(transactionManager, _weirType, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_WEIR_TYPES key.
		///		fkWeirsWeirTypes Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_weirType">Foreign key to WEIR_TYPES</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		public TList<Weir> GetByWeirType(System.String _weirType, int start, int pageLength)
		{
			int count =  -1;
			return GetByWeirType(null, _weirType, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_WEIR_TYPES key.
		///		fkWeirsWeirTypes Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_weirType">Foreign key to WEIR_TYPES</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		public TList<Weir> GetByWeirType(System.String _weirType, int start, int pageLength,out int count)
		{
			return GetByWeirType(null, _weirType, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_WEIRS_WEIR_TYPES key.
		///		FK_WEIRS_WEIR_TYPES Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_weirType">Foreign key to WEIR_TYPES</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of BesAsm.MasterData.Entities.Weir objects.</returns>
		public abstract TList<Weir> GetByWeirType(TransactionManager transactionManager, System.String _weirType, int start, int pageLength, out int count);
		
		#endregion

		#region Get By Index Functions
		
		/// <summary>
		/// 	Gets a row from the DataSource based on its primary key.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to retrieve.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <returns>Returns an instance of the Entity class.</returns>
		public override BesAsm.MasterData.Entities.Weir Get(TransactionManager transactionManager, BesAsm.MasterData.Entities.WeirKey key, int start, int pageLength)
		{
			return GetByWeirId(transactionManager, key.WeirId, start, pageLength);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the primary key PK_WEIRS index.
		/// </summary>
		/// <param name="_weirId">Primary key, weir ID</param>
		/// <returns>Returns an instance of the <see cref="BesAsm.MasterData.Entities.Weir"/> class.</returns>
		public BesAsm.MasterData.Entities.Weir GetByWeirId(System.Int32 _weirId)
		{
			int count = -1;
			return GetByWeirId(null,_weirId, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_WEIRS index.
		/// </summary>
		/// <param name="_weirId">Primary key, weir ID</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="BesAsm.MasterData.Entities.Weir"/> class.</returns>
		public BesAsm.MasterData.Entities.Weir GetByWeirId(System.Int32 _weirId, int start, int pageLength)
		{
			int count = -1;
			return GetByWeirId(null, _weirId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_WEIRS index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_weirId">Primary key, weir ID</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="BesAsm.MasterData.Entities.Weir"/> class.</returns>
		public BesAsm.MasterData.Entities.Weir GetByWeirId(TransactionManager transactionManager, System.Int32 _weirId)
		{
			int count = -1;
			return GetByWeirId(transactionManager, _weirId, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_WEIRS index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_weirId">Primary key, weir ID</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="BesAsm.MasterData.Entities.Weir"/> class.</returns>
		public BesAsm.MasterData.Entities.Weir GetByWeirId(TransactionManager transactionManager, System.Int32 _weirId, int start, int pageLength)
		{
			int count = -1;
			return GetByWeirId(transactionManager, _weirId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_WEIRS index.
		/// </summary>
		/// <param name="_weirId">Primary key, weir ID</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="BesAsm.MasterData.Entities.Weir"/> class.</returns>
		public BesAsm.MasterData.Entities.Weir GetByWeirId(System.Int32 _weirId, int start, int pageLength, out int count)
		{
			return GetByWeirId(null, _weirId, start, pageLength, out count);
		}
		
				
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_WEIRS index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_weirId">Primary key, weir ID</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns an instance of the <see cref="BesAsm.MasterData.Entities.Weir"/> class.</returns>
		public abstract BesAsm.MasterData.Entities.Weir GetByWeirId(TransactionManager transactionManager, System.Int32 _weirId, int start, int pageLength, out int count);
						
		#endregion "Get By Index Functions"
	
		#region Custom Methods
		
		
		#endregion

		#region Helper Functions	
		
		/// <summary>
		/// Fill a TList&lt;Weir&gt; From a DataReader.
		/// </summary>
		/// <param name="reader">Datareader</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">number of rows.</param>
		/// <returns>a <see cref="TList&lt;Weir&gt;"/></returns>
		public static TList<Weir> Fill(IDataReader reader, TList<Weir> rows, int start, int pageLength)
		{
			NetTiersProvider currentProvider = DataRepository.Provider;
            bool useEntityFactory = currentProvider.UseEntityFactory;
            bool enableEntityTracking = currentProvider.EnableEntityTracking;
            LoadPolicy currentLoadPolicy = currentProvider.CurrentLoadPolicy;
			Type entityCreationFactoryType = currentProvider.EntityCreationalFactoryType;
			
			// advance to the starting row
			for (int i = 0; i < start; i++)
			{
				if (!reader.Read())
				return rows; // not enough rows, just return
			}
			for (int i = 0; i < pageLength; i++)
			{
				if (!reader.Read())
					break; // we are done
					
				string key = null;
				
				BesAsm.MasterData.Entities.Weir c = null;
				if (useEntityFactory)
				{
					key = new System.Text.StringBuilder("Weir")
					.Append("|").Append((System.Int32)reader[((int)WeirColumn.WeirId - 1)]).ToString();
					c = EntityManager.LocateOrCreate<Weir>(
					key.ToString(), // EntityTrackingKey
					"Weir",  //Creational Type
					entityCreationFactoryType,  //Factory used to create entity
					enableEntityTracking); // Track this entity?
				}
				else
				{
					c = new BesAsm.MasterData.Entities.Weir();
				}
				
				if (!enableEntityTracking ||
					c.EntityState == EntityState.Added ||
					(enableEntityTracking &&
					
						(
							(currentLoadPolicy == LoadPolicy.PreserveChanges && c.EntityState == EntityState.Unchanged) ||
							(currentLoadPolicy == LoadPolicy.DiscardChanges && c.EntityState != EntityState.Unchanged)
						)
					))
				{
					c.SuppressEntityEvents = true;
					c.WeirId = (System.Int32)reader[((int)WeirColumn.WeirId - 1)];
					c.OriginalWeirId = c.WeirId;
					c.WeirName = (reader.IsDBNull(((int)WeirColumn.WeirName - 1)))?null:(System.String)reader[((int)WeirColumn.WeirName - 1)];
					c.UsNodeId = (System.Int32)reader[((int)WeirColumn.UsNodeId - 1)];
					c.DsNodeId = (reader.IsDBNull(((int)WeirColumn.DsNodeId - 1)))?null:(System.Int32?)reader[((int)WeirColumn.DsNodeId - 1)];
					c.LinkId = (reader.IsDBNull(((int)WeirColumn.LinkId - 1)))?null:(System.Int32?)reader[((int)WeirColumn.LinkId - 1)];
					c.WeirType = (System.String)reader[((int)WeirColumn.WeirType - 1)];
					c.Crown = (System.Decimal)reader[((int)WeirColumn.Crown - 1)];
					c.Crest = (System.Decimal)reader[((int)WeirColumn.Crest - 1)];
					c.Length = (System.Decimal)reader[((int)WeirColumn.Length - 1)];
					c.Coefficient = (System.Decimal)reader[((int)WeirColumn.Coefficient - 1)];
					c.EditedBy = (System.String)reader[((int)WeirColumn.EditedBy - 1)];
					c.EditReason = (System.String)reader[((int)WeirColumn.EditReason - 1)];
					c.Status = (System.String)reader[((int)WeirColumn.Status - 1)];
					c.AppendDate = (System.DateTime)reader[((int)WeirColumn.AppendDate - 1)];
					c.EditDate = (reader.IsDBNull(((int)WeirColumn.EditDate - 1)))?null:(System.DateTime?)reader[((int)WeirColumn.EditDate - 1)];
					c.EntityTrackingKey = key;
					c.AcceptChanges();
					c.SuppressEntityEvents = false;
				}
				rows.Add(c);
			}
		return rows;
		}		
		/// <summary>
		/// Refreshes the <see cref="BesAsm.MasterData.Entities.Weir"/> object from the <see cref="IDataReader"/>.
		/// </summary>
		/// <param name="reader">The <see cref="IDataReader"/> to read from.</param>
		/// <param name="entity">The <see cref="BesAsm.MasterData.Entities.Weir"/> object to refresh.</param>
		public static void RefreshEntity(IDataReader reader, BesAsm.MasterData.Entities.Weir entity)
		{
			if (!reader.Read()) return;
			
			entity.WeirId = (System.Int32)reader[((int)WeirColumn.WeirId - 1)];
			entity.OriginalWeirId = (System.Int32)reader["weir_id"];
			entity.WeirName = (reader.IsDBNull(((int)WeirColumn.WeirName - 1)))?null:(System.String)reader[((int)WeirColumn.WeirName - 1)];
			entity.UsNodeId = (System.Int32)reader[((int)WeirColumn.UsNodeId - 1)];
			entity.DsNodeId = (reader.IsDBNull(((int)WeirColumn.DsNodeId - 1)))?null:(System.Int32?)reader[((int)WeirColumn.DsNodeId - 1)];
			entity.LinkId = (reader.IsDBNull(((int)WeirColumn.LinkId - 1)))?null:(System.Int32?)reader[((int)WeirColumn.LinkId - 1)];
			entity.WeirType = (System.String)reader[((int)WeirColumn.WeirType - 1)];
			entity.Crown = (System.Decimal)reader[((int)WeirColumn.Crown - 1)];
			entity.Crest = (System.Decimal)reader[((int)WeirColumn.Crest - 1)];
			entity.Length = (System.Decimal)reader[((int)WeirColumn.Length - 1)];
			entity.Coefficient = (System.Decimal)reader[((int)WeirColumn.Coefficient - 1)];
			entity.EditedBy = (System.String)reader[((int)WeirColumn.EditedBy - 1)];
			entity.EditReason = (System.String)reader[((int)WeirColumn.EditReason - 1)];
			entity.Status = (System.String)reader[((int)WeirColumn.Status - 1)];
			entity.AppendDate = (System.DateTime)reader[((int)WeirColumn.AppendDate - 1)];
			entity.EditDate = (reader.IsDBNull(((int)WeirColumn.EditDate - 1)))?null:(System.DateTime?)reader[((int)WeirColumn.EditDate - 1)];
			entity.AcceptChanges();
		}
		
		/// <summary>
		/// Refreshes the <see cref="BesAsm.MasterData.Entities.Weir"/> object from the <see cref="DataSet"/>.
		/// </summary>
		/// <param name="dataSet">The <see cref="DataSet"/> to read from.</param>
		/// <param name="entity">The <see cref="BesAsm.MasterData.Entities.Weir"/> object.</param>
		public static void RefreshEntity(DataSet dataSet, BesAsm.MasterData.Entities.Weir entity)
		{
			DataRow dataRow = dataSet.Tables[0].Rows[0];
			
			entity.WeirId = (System.Int32)dataRow["weir_id"];
			entity.OriginalWeirId = (System.Int32)dataRow["weir_id"];
			entity.WeirName = Convert.IsDBNull(dataRow["weir_name"]) ? null : (System.String)dataRow["weir_name"];
			entity.UsNodeId = (System.Int32)dataRow["us_node_id"];
			entity.DsNodeId = Convert.IsDBNull(dataRow["ds_node_id"]) ? null : (System.Int32?)dataRow["ds_node_id"];
			entity.LinkId = Convert.IsDBNull(dataRow["link_id"]) ? null : (System.Int32?)dataRow["link_id"];
			entity.WeirType = (System.String)dataRow["weir_type"];
			entity.Crown = (System.Decimal)dataRow["crown"];
			entity.Crest = (System.Decimal)dataRow["crest"];
			entity.Length = (System.Decimal)dataRow["length"];
			entity.Coefficient = (System.Decimal)dataRow["coefficient"];
			entity.EditedBy = (System.String)dataRow["edited_by"];
			entity.EditReason = (System.String)dataRow["edit_reason"];
			entity.Status = (System.String)dataRow["status"];
			entity.AppendDate = (System.DateTime)dataRow["append_date"];
			entity.EditDate = Convert.IsDBNull(dataRow["edit_date"]) ? null : (System.DateTime?)dataRow["edit_date"];
			entity.AcceptChanges();
		}
		#endregion 
		
		#region DeepLoad Methods
		/// <summary>
		/// Deep Loads the <see cref="IEntity"/> object with criteria based of the child 
		/// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
		/// </summary>
		/// <remarks>
		/// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
		/// </remarks>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">The <see cref="BesAsm.MasterData.Entities.Weir"/> object to load.</param>
		/// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
		/// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
		/// <param name="childTypes">BesAsm.MasterData.Entities.Weir Property Collection Type Array To Include or Exclude from Load</param>
		/// <param name="innerList">A collection of child types for easy access.</param>
	    /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
	    /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
		public override void DeepLoad(TransactionManager transactionManager, BesAsm.MasterData.Entities.Weir entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
		{
			if(entity == null)
				return;

			#region LinkIdSource	
			if (CanDeepLoad(entity, "Link|LinkIdSource", deepLoadType, innerList) 
				&& entity.LinkIdSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = (entity.LinkId ?? (int)0);
				Link tmpEntity = EntityManager.LocateEntity<Link>(EntityLocator.ConstructKeyFromPkItems(typeof(Link), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.LinkIdSource = tmpEntity;
				else
					entity.LinkIdSource = DataRepository.LinkProvider.GetByLinkId(transactionManager, (entity.LinkId ?? (int)0));		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'LinkIdSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.LinkIdSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.LinkProvider.DeepLoad(transactionManager, entity.LinkIdSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion LinkIdSource

			#region DsNodeIdSource	
			if (CanDeepLoad(entity, "Node|DsNodeIdSource", deepLoadType, innerList) 
				&& entity.DsNodeIdSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = (entity.DsNodeId ?? (int)0);
				Node tmpEntity = EntityManager.LocateEntity<Node>(EntityLocator.ConstructKeyFromPkItems(typeof(Node), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.DsNodeIdSource = tmpEntity;
				else
					entity.DsNodeIdSource = DataRepository.NodeProvider.GetByNodeId(transactionManager, (entity.DsNodeId ?? (int)0));		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'DsNodeIdSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.DsNodeIdSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.NodeProvider.DeepLoad(transactionManager, entity.DsNodeIdSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion DsNodeIdSource

			#region UsNodeIdSource	
			if (CanDeepLoad(entity, "Node|UsNodeIdSource", deepLoadType, innerList) 
				&& entity.UsNodeIdSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.UsNodeId;
				Node tmpEntity = EntityManager.LocateEntity<Node>(EntityLocator.ConstructKeyFromPkItems(typeof(Node), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.UsNodeIdSource = tmpEntity;
				else
					entity.UsNodeIdSource = DataRepository.NodeProvider.GetByNodeId(transactionManager, entity.UsNodeId);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'UsNodeIdSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.UsNodeIdSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.NodeProvider.DeepLoad(transactionManager, entity.UsNodeIdSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion UsNodeIdSource

			#region StatusSource	
			if (CanDeepLoad(entity, "Status|StatusSource", deepLoadType, innerList) 
				&& entity.StatusSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.Status;
				Status tmpEntity = EntityManager.LocateEntity<Status>(EntityLocator.ConstructKeyFromPkItems(typeof(Status), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.StatusSource = tmpEntity;
				else
					entity.StatusSource = DataRepository.StatusProvider.GetByStatusId(transactionManager, entity.Status);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'StatusSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.StatusSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.StatusProvider.DeepLoad(transactionManager, entity.StatusSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion StatusSource

			#region WeirTypeSource	
			if (CanDeepLoad(entity, "WeirType|WeirTypeSource", deepLoadType, innerList) 
				&& entity.WeirTypeSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.WeirType;
				WeirType tmpEntity = EntityManager.LocateEntity<WeirType>(EntityLocator.ConstructKeyFromPkItems(typeof(WeirType), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.WeirTypeSource = tmpEntity;
				else
					entity.WeirTypeSource = DataRepository.WeirTypeProvider.GetByWeirTypeId(transactionManager, entity.WeirType);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'WeirTypeSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.WeirTypeSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.WeirTypeProvider.DeepLoad(transactionManager, entity.WeirTypeSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion WeirTypeSource
			
			//used to hold DeepLoad method delegates and fire after all the local children have been loaded.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();
			
			//Fire all DeepLoad Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			deepHandles = null;
		}
		
		#endregion 
		
		#region DeepSave Methods

		/// <summary>
		/// Deep Save the entire object graph of the BesAsm.MasterData.Entities.Weir object with criteria based of the child 
		/// Type property array and DeepSaveType.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entity">BesAsm.MasterData.Entities.Weir instance</param>
		/// <param name="deepSaveType">DeepSaveType Enumeration to Include/Exclude object property collections from Save.</param>
		/// <param name="childTypes">BesAsm.MasterData.Entities.Weir Property Collection Type Array To Include or Exclude from Save</param>
		/// <param name="innerList">A Hashtable of child types for easy access.</param>
		public override bool DeepSave(TransactionManager transactionManager, BesAsm.MasterData.Entities.Weir entity, DeepSaveType deepSaveType, System.Type[] childTypes, DeepSession innerList)
		{	
			if (entity == null)
				return false;
							
			#region Composite Parent Properties
			//Save Source Composite Properties, however, don't call deep save on them.  
			//So they only get saved a single level deep.
			
			#region LinkIdSource
			if (CanDeepSave(entity, "Link|LinkIdSource", deepSaveType, innerList) 
				&& entity.LinkIdSource != null)
			{
				DataRepository.LinkProvider.Save(transactionManager, entity.LinkIdSource);
				entity.LinkId = entity.LinkIdSource.LinkId;
			}
			#endregion 
			
			#region DsNodeIdSource
			if (CanDeepSave(entity, "Node|DsNodeIdSource", deepSaveType, innerList) 
				&& entity.DsNodeIdSource != null)
			{
				DataRepository.NodeProvider.Save(transactionManager, entity.DsNodeIdSource);
				entity.DsNodeId = entity.DsNodeIdSource.NodeId;
			}
			#endregion 
			
			#region UsNodeIdSource
			if (CanDeepSave(entity, "Node|UsNodeIdSource", deepSaveType, innerList) 
				&& entity.UsNodeIdSource != null)
			{
				DataRepository.NodeProvider.Save(transactionManager, entity.UsNodeIdSource);
				entity.UsNodeId = entity.UsNodeIdSource.NodeId;
			}
			#endregion 
			
			#region StatusSource
			if (CanDeepSave(entity, "Status|StatusSource", deepSaveType, innerList) 
				&& entity.StatusSource != null)
			{
				DataRepository.StatusProvider.Save(transactionManager, entity.StatusSource);
				entity.Status = entity.StatusSource.StatusId;
			}
			#endregion 
			
			#region WeirTypeSource
			if (CanDeepSave(entity, "WeirType|WeirTypeSource", deepSaveType, innerList) 
				&& entity.WeirTypeSource != null)
			{
				DataRepository.WeirTypeProvider.Save(transactionManager, entity.WeirTypeSource);
				entity.WeirType = entity.WeirTypeSource.WeirTypeId;
			}
			#endregion 
			#endregion Composite Parent Properties

			// Save Root Entity through Provider
			if (!entity.IsDeleted)
				this.Save(transactionManager, entity);
			
			//used to hold DeepSave method delegates and fire after all the local children have been saved.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();
			//Fire all DeepSave Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			
			// Save Root Entity through Provider, if not already saved in delete mode
			if (entity.IsDeleted)
				this.Save(transactionManager, entity);
				

			deepHandles = null;
						
			return true;
		}
		#endregion
	} // end class
	
	#region WeirChildEntityTypes
	
	///<summary>
	/// Enumeration used to expose the different child entity types 
	/// for child properties in <c>BesAsm.MasterData.Entities.Weir</c>
	///</summary>
	public enum WeirChildEntityTypes
	{
		
		///<summary>
		/// Composite Property for <c>Link</c> at LinkIdSource
		///</summary>
		[ChildEntityType(typeof(Link))]
		Link,
			
		///<summary>
		/// Composite Property for <c>Node</c> at DsNodeIdSource
		///</summary>
		[ChildEntityType(typeof(Node))]
		Node,
			
		///<summary>
		/// Composite Property for <c>Status</c> at StatusSource
		///</summary>
		[ChildEntityType(typeof(Status))]
		Status,
			
		///<summary>
		/// Composite Property for <c>WeirType</c> at WeirTypeSource
		///</summary>
		[ChildEntityType(typeof(WeirType))]
		WeirType,
		}
	
	#endregion WeirChildEntityTypes
	
	#region WeirFilterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlFilterBuilder&lt;WeirColumn&gt;"/> class
	/// that is used exclusively with a <see cref="Weir"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class WeirFilterBuilder : SqlFilterBuilder<WeirColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the WeirFilterBuilder class.
		/// </summary>
		public WeirFilterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the WeirFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public WeirFilterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the WeirFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public WeirFilterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion WeirFilterBuilder
	
	#region WeirParameterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="ParameterizedSqlFilterBuilder&lt;WeirColumn&gt;"/> class
	/// that is used exclusively with a <see cref="Weir"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class WeirParameterBuilder : ParameterizedSqlFilterBuilder<WeirColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the WeirParameterBuilder class.
		/// </summary>
		public WeirParameterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the WeirParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public WeirParameterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the WeirParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public WeirParameterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion WeirParameterBuilder
	
	#region WeirSortBuilder
    
    /// <summary>
    /// A strongly-typed instance of the <see cref="SqlSortBuilder&lt;WeirColumn&gt;"/> class
	/// that is used exclusively with a <see cref="Weir"/> object.
    /// </summary>
    [CLSCompliant(true)]
    public class WeirSortBuilder : SqlSortBuilder<WeirColumn>
    {
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the WeirSqlSortBuilder class.
		/// </summary>
		public WeirSortBuilder() : base() { }

		#endregion Constructors

    }    
    #endregion WeirSortBuilder
	
} // end namespace
